﻿#ifndef INSTRUCTIONTURNTABLECONNECT
#define INSTRUCTIONTURNTABLECONNECT

#include "ScriptInstruction.h"

class InstructionTurnTableConnect :public ScriptInstruction
{
  Q_OBJECT
private:
  ScriptRunner* scriptRunner = Q_NULLPTR;
  TurnTableCodec* turnTableCodec = Q_NULLPTR;
  TurnTableConnectionStateManager* turnTableConnectionStateManager = Q_NULLPTR;
public:
  InstructionTurnTableConnect()
  {
    scriptRunner = ScriptInstruction::getScriptRunner();
    turnTableCodec = ScriptInstruction::getTurnTableCodec();
    turnTableConnectionStateManager = ScriptInstruction::getTurnTableConnectionStateManager();
    instructionFlag = Instruction_TurnTable_Connect;
  }
  ~InstructionTurnTableConnect()
  {}
public:
  void run()override
  {
    turnTableCodec->sendInstruction(TurnTableCodec::TurnTable_Connect,0,0,0);
    StateChecker<TurnTableCodec::ConnectionState, TurnTableConnectionStateManager>::next_ifConditionReached(&TurnTableConnectionStateManager::getTurnTableConnectionState, turnTableConnectionStateManager, TurnTableCodec::State_Connected, scriptRunner->getTime_connectTimeOut(),scriptRunner);
  }
  QVector<float> getDataForSaving()override
  {
    QVector<float> savingData;
    savingData.append(instructionFlag);
    return savingData;
  }
};
#endif
